package com.taijia.chapter9;

/**
 *
 */
public class TestThread1 {
    public static void main(String[] args) {
        Thread r = new Thread(new Runner1());
        Thread t = new Thread1();
        r.start();
        t.start();
        for (int j = 100; j < 200; j++) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("main:" + j);
        }
    }
}

class Runner1 implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("runner:" + i);
        }
    }
}
class Thread1 extends Thread {
    @Override
    public void run() {
        for (int i = 200; i < 300; i++) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("thread:" + i);
        }
    }
}
